//
//  RegisterPassWordViewController.m
//  JxCarios
//
//  Created by xcq on 15/1/27.
//  Copyright (c) 2015年 xiongchuanqi. All rights reserved.
//

#import "RegisterPassWordViewController.h"

@interface RegisterPassWordViewController ()

@end


@implementation RegisterPassWordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUp];
    

}

- (void)setUp{
    self.title = _status == 1 ? @"用户注册" : @"找回密码";
    [self showNavBarWithRightTitle:nil andRightAction:nil andLeftAction:nil andCustom:NO];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


- (IBAction)commit:(id)sender {
    if (_passWord.text.length <= 0) {
        TOASTSHOW(@"请输入密码");
        return;
    }
    if(!(_passWord.text.length >= 6 && _passWord.text.length <= 15)){
        TOASTSHOW(@"密码长度应大于6位小于15位");
        return ;
    }
    
    if (_affirmPsd.text.length <= 0) {
        TOASTSHOW(@"请输入再次确认密码");
        return;
    }
    
    if (![_affirmPsd.text isEqualToString:_passWord.text]) {
        TOASTSHOW(@"两次输入不一致,请重新输入");
        return;
    }
    if (!self.dataSource) {
        self.dataSource = [CurrentDataSource  dataSourceWithRequestor:self];
    }
    self.dataSource.mobile = _mobile;
    self.dataSource.passWord = _passWord.text;
    self.dataSource.rand = [NSString stringWithFormat:@"%ld",_randCode];
     [self.dataSource registers:^(id result) {
        TOASTSHOW(_status == 1 ? @"注册成功" : @"找回密码成功");
        [self.navigationController popToRootViewControllerAnimated:YES];
    } withStatus:_status andFail:^(id result) {
        
    }];
}
@end
